<?php
declare (strict_types = 1);

namespace app\admin\controller;

use app\admin\model\GoodsProp;
use app\admin\model\GoodsPropValue;
use app\BaseController;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Index extends BaseController
{
    //首页
    public function index()
    {
        return View::fetch();
    }

    //网站设置页
    public function info()
    {
        return View::fetch();
    }

    //轮播页
    public function adv()
    {
        return View::fetch();
    }

    //权限组页
    public function auth()
    {
        return View::fetch();
    }

//        public function attr()
//    {
//        $rt = Db::table('ecm_goods_prop')
//            ->select();
//        if ($rt->isEmpty()) {
//            $rt->toArray();
//            exit;
//        } else {
//            $rt->toArray();
//            View::assign('arr', $rt);
//        }
//        return View::fetch();
//    }
    public function attr()
    {
        $keywords = Request::get('keywords', '', "trim,htmlspecialchars,strip_tags");
        $prop_value = Request::get('prop_value', [], "trim,htmlspecialchars,strip_tags");
        $data=[
            'pname'=>$keywords,
            'prop_value'=>$prop_value,
        ];
        View::assign($data);
        $list1 = GoodsProp::getGoodsPropList($data,input('get.'));
        $sousuo1 = GoodsPropValue::getGoodsPropValueList();
        View::assign('list',$list1);
        View::assign('sousuo', $sousuo1);
        return View::fetch();
    }
    //权限组添加页
    public function auth_add()
    {
        return View::fetch();
    }
    //        if ($keywords != '') {
//            $where .= " and pname like '%{$keywords}%'";
//        }
    //        if (!empty($prop_value)) {
//            foreach ($prop_value as $vv) {
//                $list1->whereFindInSet('pvalues', $vv);
//            }
//        }
//        $list = $list1->select()->toArray();
//        $sousuo = $sousuo1->select();
//        if (empty($list)) {
//            View::assign('list', $list);
//        } else {
//            foreach ($list as $k => $v) {
//                $x = Db::table('ecm_goods_prop_value')
//                    ->field('pid,prop_value')
//                    ->where("vid in ({$v['pvalues']})")->select();
//                $arr = [];
//                foreach ($x as $vv) {
//                    $arr[] = $vv['prop_value'];
//                    $a = implode(',', $arr);
//                }
//                $v['a'] = $a;
//                $list[$k]['z'] = $a;
//                View::assign('arr', $arr);
//            }
//            View::assign('list', $list);
//        }
//        View::assign('prop_values', $prop_value);
    //订单列表页
    public function order_list()
    {
        return View::fetch();
    }

    //订单查看页
    public function order_detail()
    {
        return View::fetch();
    }

    //修改密码页
    public function pass()
    {
        return View::fetch();
    }

    //管理员列表页
    public function user()
    {
        return View::fetch();
    }

    //管理员添加页
    public function user_add()
    {
        return View::fetch();
    }

    //管理员修改页
    public function user_edit()
    {
        return View::fetch();
    }

    //会员添加页
    public function vip_add()
    {
        return View::fetch();
    }

    //会员列表页
    public function vip_list()
    {
        return View::fetch();
    }
}
